package ui
{
	import com.greensock.easing.Linear;
	
	import flash.display.Sprite;
	
	import globals.$athena;
	
	import slices.FunctionSlice;
	import slices.TimeSlice;
	import slices.TweenSlice;
	
	public class Dialog extends Sprite implements InputHandler
	{
		public static var FADE_IN_SPEED:Number = 0.3;
		public static var FADE_OUT_SPEED:Number = 0.15;

		public function Dialog()
		{
			super();
		}
		
		public function display(container:Sprite):TimeSlice {			
			this.scaleX = 0;
			this.scaleY = 0;
			this.alpha = 0;
			addToParent(container);
			var tween:TweenSlice = new TweenSlice(this, FADE_IN_SPEED, {scaleX:1, scaleY:1, alpha:1, ease:Linear.easeNone});
			tween.appendNext(new FunctionSlice(active));
			$athena.addTimeSlice(tween);
			return tween;
		}
		
		public function disappear():TimeSlice {
			deactive();
			var tween:TweenSlice = new TweenSlice(this, FADE_OUT_SPEED, {scaleX:0, scaleY:0, alpha:0, ease:Linear.easeNone});
			tween.appendNext(new FunctionSlice(removeFromParent));
			$athena.addTimeSlice(tween);			
			return tween;
		}
		
		public function addToParent(container:Sprite):void {
			container.addChild(this);
		}
		
		public function removeFromParent():void {
			if (parent != null) {
				parent.removeChild(this);
			}
		}
		
		public function active():void {
			
		}
		
		public function deactive():void {
			
		}

	}
}